import pandas as pd
from copy import deepcopy
from pypinyin import pinyin

pd.set_option('display.unicode.ambiguous_as_wide', True)
pd.set_option('display.unicode.east_asian_width', True)

df = pd.read_excel('./超市营业额2.xlsx')

print('按交易额和工号降序排序：')
print(df.sort_values(by=['交易额', '工号'], ascending=False)[:12])

print('按交易额降序、工号升序排序：')
print(df.sort_values(by=['交易额', '工号'], ascending=[False, True])[:12])

print('按工号升序排序：')
print(df.sort_values(by='工号', ascending=True)[:10])

print('按列名升序排序：')
print(df.sort_index(axis=1, ascending=True)[:10])

dff = deepcopy(df)
dff['拼音'] = dff.姓名.map(pinyin)
print(dff.sort_values(by='拼音').drop('拼音', axis=1)[:10])
